/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */


package com.android1.amarena2d.input;

import com.android1.amarena2d.commons.Size;
import com.android1.amarena2d.engine.AmarenaCamera;
import com.android1.amarena2d.engine.TouchSpotSystem;
import com.badlogic.gdx.math.Vector2;

public class CustomTouchSpot extends BaseTouchSpot implements TouchSpot {

    private final Vector2 position = new Vector2();
    private final Size size = new Size();
    private boolean active = true;
    private final AmarenaCamera camera;

    public CustomTouchSpot(int priority, boolean active, AmarenaCamera camera) {
        super(priority);
        this.active = active;
        this.camera = camera;
    }

    public CustomTouchSpot(final float x, final float y, final float width, final float height, AmarenaCamera camera) {
        this.position.x = x;
        this.position.y = y;
        this.size.width = width;
        this.size.height = height;
        this.camera = camera;
        this.priority = nextPriority();
    }

    public void setXY(float x, float y) {
        position.x = x;
        position.y = y;
    }

    public void setX(float x) {
        position.x = x;
    }

    public void setY(float y) {
        position.y = y;
    }

    public void setWidth(final float width) {
        size.width = width;
    }

    public void setHeight(final float heigth) {
        size.height = heigth;
    }

    @Override
    public int getPriority() {
        return priority;
    }

    @Override
    public AmarenaCamera getCamera() {
        return camera;
    }

    @Override
    public boolean isHit(float x, float y) {
        return TouchSpotSystem.isHit(x, y, position.x, position.y, size.width, size.height);
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @Override
    public boolean isActive() {
        return active;
    }


}
